package 第五轮工作.沈阳航空航天大学;

import com.alibaba.excel.EasyExcel;
import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import 第五轮工作.天津理工.TJLUBean;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class SYHKHTU {
    public static void main(String[] args) throws IOException {
        SYHKHTTUBean syhkhttuBean = null;
        List<SYHKHTTUBean> syhkhttuBeans = new ArrayList<>();
        int s = 3;
        String url = "";
        for (int i = 0; i < 4; i++) {
            if (i == 0) {
                url = "szdw.htm";
            }
            if (i == 1) {
                s = 6;
                url = "szdw/3.htm";
            }
            if (i == 2) {
                s = 6;
                url = "szdw/2.htm";
            }
            if (i == 3) {
                s = 6;
                url = "szdw/1.htm";
            }
            Connection connect = Jsoup.connect("https://jd.sau.edu.cn/xygk/" + url);
            Document post = connect.post();
            for (Element elementsByClass : post.getElementsByClass("text-list")) {
                for (Element element : elementsByClass.getElementsByTag("li")) {
                    for (Element li : element.getElementsByTag("li")) {
                        syhkhttuBean = new SYHKHTTUBean();
                        syhkhttuBean.setName(li.getElementsByTag("a").text());
                        String n_url = "https://jd.sau.edu.cn/" + li.getElementsByTag("a").attr("href").substring(s);
                        Connection connect1 = Jsoup.connect(n_url);
                        Document post1 = connect1.post();
                        Element vsbContent = post1.getElementById("vsb_content");
                        syhkhttuBean.setQy(vsbContent.getElementsByClass("vsbcontent_img").text());
                        syhkhttuBeans.add(syhkhttuBean);
                    }
                }
            }
        }
        EasyExcel.write("src/main/java/第五轮工作/沈阳航空航天大学/SYHKHTU.xlsx", SYHKHTTUBean.class).sheet("user").doWrite(syhkhttuBeans);
    }
}
